<template>
    <div class="icon-index">
        <div class="item" v-for="item in props.list" :key="item.name" :style="`width:${100 / row}%`">
            <div class="content">
                <div class="icon icon1" v-if="props.type == 1">
                    <img :src="item.icon" alt="" />
                </div>
                <div class="text">
                    <div class="text-top">
                        {{ item.name }}
                    </div>
                    <div class="text-bottom">
                        <div class="count">{{ item.count }}</div>
                        <div class="unit">{{ item.unit }}</div>
                    </div>
                </div>
                <div class="icon" v-if="props.type == 0">
                    <img :src="item.icon" alt="" />
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { PropType } from 'vue'
import { getAssetsFile } from '@/utils'
interface item {
    name: string
    count: number
    unit: string
    icon: any
}

const props = defineProps({
    list: {
        type: Object as PropType<item[]>,
        default: () => {
            return [
                {
                    name: '车位总数',
                    count: 12834,
                    unit: '个',
                    icon: getAssetsFile('icon/icon_车位@2x.png')
                },
                {
                    name: '占地面积',
                    count: 834,
                    unit: '万m²',
                    icon: getAssetsFile('icon/icon_面积@2x.png')
                },
                {
                    name: '占地面积',
                    count: 834,
                    unit: '万m²',
                    icon: getAssetsFile('icon/icon_面积@2x.png')
                }
            ]
        }
    },
    row: {
        type: Number,
        default: 3
    },
    type: {
        type: Number,
        default: 0
    }
})
</script>

<style lang="scss" scoped>
.icon-index {
    width: 100%;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 5px;
    .item {
        width: 33.3%;
        padding-right: 5px;
        padding-left: 5px;
        .content {
            background: linear-gradient(98deg, #05152055 0%, #142b4b55 0.4%);
            width: 100%;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            height: 60px;
            padding: 5px;
        }
        .icon {
            width: 24px;
            height: 100%;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            img {
                width: 24px;
            }
        }
        .icon1 {
            width: 40px;
            margin-right: 5px;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            img {
                width: 40px;
            }
        }
        .text {
            width: 100px;
            margin-right: 5px;
            .text-top {
                font-size: 14px;
                font-family: 'OPPOSans';
                letter-spacing: 1px;
                color: rgba($color: #ffffff, $alpha: 0.8);
                padding-bottom: 3px;
                border-bottom: 1px solid rgba(255, 255, 255, 0.253);
            }
            .text-bottom {
                display: flex;
                align-items: flex-end;
                .count {
                    font-family: Tencent, serif;
                    color: #86dbff;
                    font-size: 23px;
                }
                .unit {
                    font-size: 14px;
                    padding-left: 5px;
                    font-family: 'OPPOSans';
                    letter-spacing: 1px;
                    color: #fff;
                }
            }
        }
    }
}
</style>
